from sqlalchemy import Column, Integer, Numeric, String, Text

from .base import BaseModel


class MemberDo(BaseModel):
    __tablename__ = "member"
    __table_args__ = {"comment": "会员表"}

    user_id = Column(Integer,
                     primary_key=True,
                     index=True,
                     autoincrement=True,
                     comment="用户id")
    mobile = Column(String(20), nullable=True, comment='手机号')

    nick_name = Column(String,
                       unique=False,
                       index=False,
                       nullable=True,
                       comment="用户昵称")
    gender = Column(String(10), nullable=True, comment='性别')
    country = Column(String(50), nullable=True, comment='国家')
    province = Column(String(50), nullable=True, comment='省份')
    city = Column(String(50), nullable=True, comment='城市')
    address_id = Column(Integer, nullable=True, comment='默认地址ID')
    balance = Column(Numeric(18, 2), nullable=True, default=0, comment='余额')
    points = Column(Integer, nullable=True, default=0, comment='积分')
    pay_money = Column(Numeric(18, 2),
                       nullable=True,
                       default=0,
                       comment='累计消费')
    expend_money = Column(Numeric(18, 2),
                          nullable=True,
                          default=0,
                          comment='已支出金额')
    grade_id = Column(Integer, nullable=True, comment='会员等级ID')
    platform = Column(String(20), nullable=True, comment='注册平台')
    last_login_time = Column(Integer, nullable=True, comment='最后登录时间(Unix 秒)')
    current_oauth = Column(Text, nullable=True, comment='当前 OAuth 信息(JSON)')
    avatar_url = Column(Text, nullable=True, comment='头像完整 URL')
    avatar_id = Column(Integer, nullable=True, comment='头像文件')
